import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 分层审核区域设置信息 */
export interface AuditArea {
  id: number // id
  deptId?: number // 部门id
  dutyUserId: number // 负责人
  parentDeptId?: number // 上级部门
}

// 分层审核区域设置 API
export const AuditAreaApi = {
  // 查询分层审核区域设置分页
  getAuditAreaPage: async (params: any) => {
    return await request.get({ url: `/business/audit-area/page`, params })
  },
  // 查询分层审核区域设置所有
  getAuditAreaDeptIds: async () => {
    return await request.get({ url: `/business/audit-area/getIds` })
  },

  // 查询分层审核区域设置详情
  getAuditArea: async (id: number) => {
    return await request.get({ url: `/business/audit-area/get?id=` + id })
  },

  // 新增分层审核区域设置
  createAuditArea: async (data) => {
    return await request.post({ url: `/business/audit-area/create`, data })
  },

  // 修改分层审核区域设置
  updateAuditArea: async (data: AuditArea) => {
    return await request.put({ url: `/business/audit-area/update`, data })
  },

  // 删除分层审核区域设置
  deleteAuditArea: async (id: number) => {
    return await request.delete({ url: `/business/audit-area/delete?id=` + id })
  },

  /** 批量删除分层审核区域设置 */
  deleteAuditAreaList: async (ids: number[]) => {
    return await request.delete({ url: `/business/audit-area/delete-list?ids=${ids.join(',')}` })
  },

  // 导出分层审核区域设置 Excel
  exportAuditArea: async (params) => {
    return await request.download({ url: `/business/audit-area/export-excel`, params })
  }
}
